package com.itheima.oop.Demo03;

public class Student {
    private String name;
    private int age;

    //public  Student(){}
    public void setName(String name) {
        this.name = name;
        System.out.println(this);
    }

    public String getName() {
        return name;
    }

    public int getAge() {
        return age;
    }

    public void setAge(int age) {
        if (age >= 0 && age <= 120){
            this.age = age;
        }else{
            System.out.println("年龄不合理");
        }
    }

    public void study() {
        System.out.println(age + "岁的" + name + "正在学习");
    }
}
